<?
// paz - link za order na corporate i business package
$query = "SELECT name, product_id FROM products WHERE reseller_id='".$GLOBALS['id']."' AND type='plan' AND name IN ('Business','Corporate')";
$GLOBALS['master_db']->query($query);
$mapped = $GLOBALS['master_db']->getMapped('name');
// end paz
$status_map = array('0'=>'Unapproved Registration','1'=>'Unapproved Renewal','2'=>'Unapproved Tranfer','3'=>'Unapproved Change','4'=>'Approved','5'=>'Rejected','6'=>'Suspended','7'=>'Transferring','8'=>'Transfer Fail','9'=>'Domain Expired',''=>'-');
$domain_list = list_reseller_domains_($GLOBALS['id']);

$params[sid] = $GLOBALS['sid'];
$params[action] = 'details_domain';

$params[domain_action] = 'whois';
$params[dns_cluster_page] = true;
$details_url_whois = "$GLOBALS[baseURL]/$GLOBALS[webDIR]/?".encode_params($params);

$params[domain_action] = 'dns';
$details_url_dns = "$GLOBALS[baseURL]/$GLOBALS[webDIR]/?".encode_params($params);

unset($params[domain_action], $params[dns_cluster_page]);
$params[action] = 'emails';
$emails_url = "$GLOBALS[baseURL]/$GLOBALS[webDIR]/?".encode_params($params);


$domain_type = array('norcp','rcpnomdns','rcpmdns');

if($domain_list){
	foreach($domain_list as $dom=>$arr){
		if($arr['dns_purchase_id']){
			$private_dns = true;
			break;
		}
	}

	$tbl = "<form id='sform' name='sform' method='post' onSubmit='return
false;'><table class=bTable cellspacing=0 cellspacing=0 width=100%>
			<tr>
				<!--<th>X</th>-->
				<th>Domain</th>
				<th>Status</th>
				<th>DNS Check</th>
				<!--<th>Whois</th>-->
				<th>Expires on</th>
				<th>Take Action</th>
			</tr>";

	foreach($domain_list as $dom=>$arr){
		if($arr['rp_product_id']){
			if($arr['dns_purchase_id']){
                                $query = "SELECT ds.ns_type, ds.mail_server, p.rp_product_id, ds.dns_dom_id, ds.dns_dom_name FROM dns_cluster.domain_settings ds LEFT JOIN purchases p ON(ds.dns_purchase_id=p.purchase_id) WHERE ds.dns_purchase_id=".$arr['dns_purchase_id'];

                                $GLOBALS['master_db']->query($query);
                                if($GLOBALS['master_db']->error){
                                        mail('errors@bastun.net', 'Could Not Get Private DNS rp_product_id', $query);
                                }

                                $dns_rp_product = $GLOBALS['master_db']->getNext();
                                $tmp = array_flip($GLOBALS['rp_products']);
                                $tmp1 = array_flip($GLOBALS['ns_types']);

                                $renew_params = 'domain::renewal_'.$dom;
                                $renew_params .= '|products::'.$tmp[($dns_rp_product['rp_product_id'])];
                                $renew_params .= '|ns_type::'.$tmp1[($dns_rp_product['ns_type'])];
                                $renew_params .= $dns_rp_product['mail_server'] == 't' ? '|mail_server::yes' : '';

				$domain_list[$dom][$type] = 'rcpmdns';
				$rcpmdns = true;

				$select = "
					<select name='dom_act' ".(!in_array($arr['flags'], array(4,9)) ? ' disabled ' : '')." onChange=\"SelectEvent(this);\">
						<option value=\"\">
						<option value=\"renewalServices('$renew_params')\">Renew
						<option value=\"fSubmit('$details_url_whois','$dom');\">Edit Whois
						<option value=\"LoadPage('managednsDomains', ''); var timeoutID = setTimeout('document.getElementById($dns_rp_product[dns_dom_id]).selected = true;LoadDnsDomainInfo(\'dns_dom_id::$dns_rp_product[dns_dom_id]\');', 3000);\">Manage DNS
						<!--<option value='new_owner'>New Owner-->
						<option value=\"document.location.href = '$emails_url';\">Set E-mails
					</select>
				";
			}else{
				$tmp = array_flip($GLOBALS['rp_products']);
				$domain_list[$dom][$type] = 'rcpnomdns';

				if(strtotime($arr['expire_date']) - strtotime("+1 year") > 0){
					$add_mdns_params = 'domain::addmdns2_'.$dom;
				}else{
					$add_mdns_params = 'domain::addmdns1_'.$dom;
				}

				$rcpnomdns = true;
				$select = "
					<select name='dom_act' ".(!in_array($arr['flags'], array(4,9)) ? ' disabled ' : '')." onChange=\"SelectEvent(this);\">
						<option value=\"\">
						<option value=\"renewalServices('domain::renewal_".$dom."|products::".$tmp[($arr['rp_product_id'])]."')\">Renew
						<option value=\"fSubmit('$details_url_dns','$dom');\">Edit Name Servers
						<option value=\"fSubmit('$details_url_whois','$dom');\">Edit Whois
						".($private_dns ? "" : "<option value=\"goAddMNDS('$add_mdns_params');\">Add Private DNS")."
						<!--<option value='new_owner'>New Owner-->
						<option value=\"document.location.href = '$emails_url';\">Set E-mails
					</select>
				";
			}
		}else{
			$domain_list[$dom][$type] = 'norcp';
			$tmp_split_dom = explode('.', $dom);
			if(count($tmp_split_dom) == 2 and in_array($tmp_split_dom[1],array('com','net','org','info','us','biz'))){
				$transfer_flag = true;
			}
			$norcp = true;
			$select = "
				<select name='dom_act' onChange=\"SelectEvent(this);\">
					<option value=\"\">
					".($transfer_flag ?  "<option value=\"goTransfer('$dom');\">Transfer" : "")."
					<option value=\"fSubmit('$details_url_whois','$dom');\">View Whois
					<option value=\"document.location.href = '$emails_url';\">Set E-mails
					<option value=\"if(confirmSubmit('Are you shure you want to delete the selected domain?')){ delDomains('domains::$dom'); }\">Delete
				</select>
			";
		}
		$tbl .=	"<tr>
			<!--<td><input type=radio name=domains value='$dom'></td>-->
			<td ".($arr['dns_purchase_id'] ? ' style="padding-left:10px;"><img align="absmiddle" src="domain/images/ico_managed_dns_orange.gif" alt="Added DNS" width="14" height="14" border="0"> ' : 'style="padding-left:24px;">&nbsp')."<a href='http://$dom' target=_blank>$dom</a></td>
			<td align=center>".($status_map[($arr['flags'])])."</td>
			<td align=center>".(dns_check($dom) ? '<img align="absmiddle" src="domain/images/ok.gif" alt="YES" width="11" height="17" border="0">' : '<img align="absmiddle" src="domain/images/ok_no_02.gif" alt="NO" width="11" height="17" border="0">').($arr[flags]==4 ? "<!--<a href='#' onClick=\"fSubmit('$details_url_dns','$dom');return false;\">[change]</a>-->" : "")."</td>
			<!--<td align=center><a href='#' onClick=\"fSubmit('$details_url_whois','$dom');return false;\">".($arr[flags]==4 ? '[change]' : '[view]')."</a></td>-->
			<td align=center>".(($arr[flags]==4 or $arr[flags]==9) ? "[".date('m/d/Y',strtotime($arr[expire_date]))."]" : '-')."</td>
			<td align=left>$select</td>
		</tr>
		";
	}
	$tbl .= '</table><input type=hidden name="add_param"></form>';
	$tbl = "<p>Manage your domain(s) with the available controls below:</p>".
			$tbl.
			'<!--<p align="center"><input type="submit" value="Set DNS &amp; Mail Server">&nbsp;&nbsp;&nbsp;<input type="submit" value="Renew Domain">&nbsp;&nbsp;&nbsp;<input type="button" value="Delete Domain" onClick="if(confirmSubmit(\'Are you shure you want to delete the selected domain?\')){delDomains(fetchForm());}return false;"></p>--><br />';
}else{
	$nodomain = true;
}

if($rcpmdns){
	$div_block = 'rcpmdns';
}elseif($rcpnomdns){
	$div_block = 'rcpnomdns';
}elseif($norcp){
	$div_block = 'norcp';
}elseif($nodomain){
	$div_block = 'nodomain';
}

?>
<div id="nodomain" style="display:<? echo($div_block == 'nodomain' ? 'block' : 'none'); ?>;">
   <br />
   <strong>No domains have been added to your account yet</strong>
   <br />
   <p>Currently you do not have any domain names registered with or transferred to ResellersPanel. Once you register or transfer a domain name for your reseller purposes, you will gain full control over it and the ability to change the DNS settings and Whois contacts at any time.</p>
     <table class="marketing_tip" width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <th colspan="2" class="marketing_head" align="left">&nbsp;&nbsp;Always aim at maximum reseller anonymity!</th>
         </tr>
         <tr>
           <td width="50" align="center" bgcolor="fffee8" valign="top"><img src="domain/images/ico_my_domains_01_tip.gif" alt="Marketing Tip" width="36" height="41"></td>
           <td bgcolor="fffee8"><p><strong>We recommend that you use one domain and brand name everywhere and for everything that has to do with your clients. A few tips:</strong></p>
           <blockquote>
               <p><strong>a. </strong>The domain name has to represent your brand. It would be the best option to have your domain and brand name in total synchronicity;</p>
               <p><strong>b. </strong>Use the same domain name for your private DNS to resolve the domains of your clients (regardless of the server on which they are hosted);</p>
               <p>Example:<br>
                 <strong>ns1.your-private-brand.com<br>
               ns2.your-private-brand.com</strong></p>
               <p>where your-private-brand.com should be your Brand Name, Company Name or DBA (Doing Business As) name;</p>
               <p><strong>c.</strong> Use the same domain (your-private-brand.com) as an SMTP/POP3/IMAP mail server for every single e-mail box that your clients have:</p>
               <p>Example: <br><strong>mail.your-private-brand.com</strong></p>
               <br />
           </blockquote>
           </td>
         </tr>
     </table>
     <br />
     <table class="marketing_tip" width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <th colspan="2" class="marketing_head" align="left">&nbsp;&nbsp;Always use a domain name if you use a website template!</th>
         </tr>
         <tr>
           <td width="50" align="center" bgcolor="fffee8" valign="top"><img src="domain/images/ico_my_domains_02_tip.gif" alt="Marketing Tip" width="39" height="44"></td>
           <td bgcolor="fffee8"><p><strong>If you use one of our predefined templates, we recommend that you register, transfer or add a domain name, which will point to it. </strong></p>
             <p>That domain name will open your store and you would not be having any problems in case you want to advertise your store through Google AdWords, Yahoo!, MSN, Overture, etc.</p>
             <blockquote>
               <strong>&raquo; Domain Registration or Transfer: <font color="green">$8.00/year</font><br>
               &raquo; Private DNS: <font color="green">$20.00 or $40.00 a year</font><br>
               &raquo; SMTP/POP3/IMAP mail server: <font color="green">FREE</font> <font color="red">*</font></strong><br />
             </blockquote>
            <p><font color="red">*</font> Available only upon activation of a Private DNS package (1 or 2). </p>
           </td>
         </tr>
     </table>
</div>
<div id="rcpnomdns" style="display:<? echo($div_block == 'rcpnomdns' ? 'block' : 'none'); ?>;">
   <br />
   <table class="marketing_tip" width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <th colspan="2" class="marketing_head" align="left">&nbsp;&nbsp;Always aim at maximum reseller anonymity!</th>
     </tr>
     <tr>
       <td width="50" align="center" bgcolor="fffee8" valign="top"><img src="domain/images/ico_my_domains_01_tip.gif" alt="Marketing Tip" width="36" height="41"></td>
       <td bgcolor="fffee8"><p><strong>Increase your brand's awareness among potential and existing customers.</strong></p>
       <p>We recommend that you create your own website for reseller purposes. According to your personal needs you can use:</p>
       <blockquote>
           <p><strong>a. </strong>your-private-brand.com for your Private DNS to resolve the domains of your clients (regardless of the server on which they are hosted);</p>
           <p>Example:<br>
             <strong>ns1.your-private-brand.com<br>ns2.your-private-brand.com</strong></p>
           <p><strong>b. </strong>your-private-brand.com as an SMTP/POP3/IMAP mail server for every single e-mail box that your clients have.</p>
           <p>Example: <br><strong> mail.your-private-brand.com</strong></p><br />
       </blockquote>
       </td>
     </tr>
   </table>
</div>
<div id="norcp" style="display:<? echo($div_block == 'norcp' ? 'block' : 'none'); ?>;">
   <br />
   <table class="marketing_tip" width="100%" border="0" cellspacing="0" cellpadding="0">
         <tr>
           <th colspan="2" class="marketing_head" align="left">&nbsp;&nbsp;Always aim at maximum reseller anonymity!</th>
         </tr>
         <tr>
           <td width="50" align="center" bgcolor="fffee8" valign="top"><img src="domain/images/ico_my_domains_01_tip.gif" alt="Marketing Tip" width="36" height="41"></td>
           <td bgcolor="fffee8"><p><strong>Transfer your-private-brand.com to us and increase the popularity of your brand.</strong></p>
           <p>We recommend that you create your own website for reseller purposes. According to your personal needs you can use:</p>
           <blockquote>
               <p><strong>a. </strong>your-private-brand.com for your Private DNS to resolve the domains of your clients (regardless of the server on which they are hosted);</p>
               <p>Example:<br>
                 <strong>ns1.your-private-brand.com<br>ns2.your-private-brand.com</strong></p>
               <p><strong>b. </strong>your-private-brand.com as an SMTP/POP3/IMAP mail server for every single e-mail box that your clients have.</p>
               <p>Example: <br><strong>mail.your-private-brand.com</strong><br />
               </p>
             </blockquote>
           </td>
         </tr>
       </table>
</div>
<div id="rcpmdns" style="display:<? echo($div_block == 'rcpmdns' ? 'block' : 'none'); ?>;">
   <br/>
   <table class="marketing_tip" width="100%" border="0" cellspacing="0" cellpadding="0">
     <tr>
       <th colspan="2" class="marketing_head" align="left">&nbsp;&nbsp;Be unique and inventive!</th>
     </tr>
     <tr>
       <td width="50" align="center" bgcolor="fffee8" valign="top"><img src="domain/images/ico_my_domains_01_tip.gif" alt="Marketing Tip" width="36" height="41"></td>
       <td bgcolor="fffee8"><p>There is a huge supply of creative energy in everyone, which stimulates the creation of unique works.   The proof of the existence of this creative energy is the wide variety of the surrounding world. Variety and uniqueness, surrounding us and spouting out from within us. Unfortunately, many people fail to take advantage of this creative resource given from nature in their everyday work.</p>
       <p>We recommend that you create your own website for reseller purposes. According to your personal needs you can use:</p>
       <blockquote>
           <p><strong>a. </strong>our remote domain search and order forms;<br /></p>
           <p><strong>b.</strong> the ResellersPanel API with its own billing system (for advanced resellers);</p>
       </blockquote>
       <p>In both cases, you will need a professional hosting service like ours for your website. Choose the option that suits you most:</p>
       <blockquote>
           <strong>I. </strong>Create a small hosting package with the Liquid Plan Builder and develop your ideas. For example: 50 MB Disk Space, 1 GB Bandwidth only for $2.85/month;<br />
           <br />
           <strong>II.</strong> If the parameters of the above-mentioned example do not correspond to your current needs, order a <a href='?action=order&plan=<?=$mapped['Corporate'];?>'>Corporate package</a> at the wholesale price. We will send you our gift - a free ResellersPanel T-shirt (unisex XL size);</blockquote>
       </td>
     </tr>
   </table>
</div>
<?

echo $tbl;
//echo "<script>alert(document.getElementById('$div_block'));document.getElementById('$div_block').style.display = 'block';</script>";

if($tbl){
?>
<p>
        <img align="absmiddle" src="domain/images/ico_managed_dns_orange.gif" alt="Added DNS" width="14" height="14" border="0">
 - Private DNS has been added for this domain name. You can modify the service's settings from the Private DNS section.
</p>
<p>
	<img align="absmiddle" src="domain/images/ok.gif" alt="YES" width="11" height="17" border="0">
 - This domain name has the required DNSes set in order to operate with our system.
</p>
<p>
	<img align="absmiddle" src="domain/images/ok_no_02.gif" alt="NO" width="11" height="17" border="0">
 - This domain name does not have the required DNSes set in order to operate with our system.
Please update them to the following ones: <b>dns1.supremecenter.com</b> and <b>dns2.supremecenter.com</b>
</p>
<?
}
?>